'use strict';

goog.provide('Blockly.Python.servo');

goog.require('Blockly.Python');

Blockly.Python.servo_move = function() {
  var dropdown_pin = Blockly.Python.valueToCode(this, 'PIN', Blockly.Python.ORDER_ATOMIC);
  var value_degree = Blockly.Python.valueToCode(this, 'DEGREE', Blockly.Python.ORDER_ATOMIC);

  Blockly.Python.definitions_['setup_output_' + dropdown_pin]='await self.servo_config(["' + dropdown_pin+ '","544", "2400"])';

  var code =  'await self.analog_write(["' + dropdown_pin + '", ' + value_degree + '])\n';
  return code;
};


Blockly.Python.servo_read_degrees = function() {
  var dropdown_pin = Blockly.Python.valueToCode(this, 'PIN', Blockly.Python.ORDER_ATOMIC);



  var code = 'servo_' + dropdown_pin + '.read()';
  return code;
};


Blockly.Python.green_servo_move = function() {
  var dropdown_pin ="7";
  var value_degree = Blockly.Python.valueToCode(this, 'DEGREE', Blockly.Python.ORDER_ATOMIC);


 Blockly.Python.definitions_['setup_output_' + dropdown_pin]='await self.servo_config(["' + dropdown_pin+ '","544", "2400"])';

  var code =  'await self.analog_write(["' + dropdown_pin + '", ' + value_degree + '])\n';
  return code;
};


Blockly.Python.white_servo_move = function() {
  var dropdown_pin ="11";
  var value_degree = Blockly.Python.valueToCode(this, 'DEGREE', Blockly.Python.ORDER_ATOMIC);

  Blockly.Python.definitions_['setup_output_' + dropdown_pin]='await self.servo_config(["' + dropdown_pin+ '","544", "2400"])';

  var code =  'await self.analog_write(["' + dropdown_pin + '", ' + value_degree + '])\n';
  return code;
};

Blockly.Python.blue_servo_move = function() {
  var dropdown_pin ="8";
  var value_degree = Blockly.Python.valueToCode(this, 'DEGREE', Blockly.Python.ORDER_ATOMIC);


  Blockly.Python.definitions_['setup_output_' + dropdown_pin]='await self.servo_config(["' + dropdown_pin+ '","544", "2400"])';

  var code =  'await self.analog_write(["' + dropdown_pin + '", ' + value_degree + '])\n';
  return code;
};


Blockly.Python.black_servo_move = function() {
  var dropdown_pin ="13";
  var value_degree = Blockly.Python.valueToCode(this, 'DEGREE', Blockly.Python.ORDER_ATOMIC);

  Blockly.Python.definitions_['setup_output_' + dropdown_pin]='await self.servo_config(["' + dropdown_pin+ '","544", "2400"])';

  var code =  'await self.analog_write(["' + dropdown_pin + '", ' + value_degree + '])\n';
  return code;
};

Blockly.Python.red_servo_move = function() {
  var dropdown_pin ="4";
  var value_degree = Blockly.Python.valueToCode(this, 'DEGREE', Blockly.Python.ORDER_ATOMIC);


  Blockly.Python.definitions_['setup_output_' + dropdown_pin]='await self.servo_config(["' + dropdown_pin+ '","544", "2400"])';

  var code =  'await self.analog_write(["' + dropdown_pin + '", ' + value_degree + '])\n';
  return code;
};
